from optparse import OptionParser
from urldb.control.populate import Populate
from urldb.view.cmdline import CmdLine

def init_parser():
    parser = OptionParser()
    parser.set_defaults(
        create=True,
        schema=None
    )
    parser.add_option(
        "-c", "--create", action="store_true", dest="create",
        help="Create database tables"
    )
    parser.add_option(
        "-d", "--database", dest="database",
        help="Database connection string for engine"
    )
    parser.add_option(
        "-s", "--schema", dest="schema",
        help="Optional database schema name"
    )
    (options, args) = parser.parse_args()
    return options


def main():
    options = init_parser()
    c = Populate(options)
    v = CmdLine(c)
    c.insert()
    v.printTables()


if __name__ == '__main__':
    main()

